/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package webServices;

import businessLogic.DataMgr;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.jws.WebService;
import persistence.Medium;
import persistence.SimpleBook;

/**
 *
 * @author breinesg
 */
@Stateless
@LocalBean
@WebService(serviceName="OtherService")
public class OtherService {
    @EJB
    private DataMgr dm;
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
    public void addBook(String title, String isb, String author) {
        dm.addBook(title, isb, author);
    }
    public List<String> listMedia() {
        List<String> strList = new ArrayList<String>();
        List<Medium> result =  dm.getAllMedia();
        if ( result.size() > 0 ) {
            if ( result.get(0) instanceof SimpleBook ) {
                strList.add(result.get(0).getTitle());
            }
        }
        return strList;
    }
}
